//
//  OSTabBarController.m
//  百思不得姐
//
//  Created by gl on 16/2/19.
//  Copyright © 2016年 CoderC. All rights reserved.
//

#import "OSTabBarController.h"
#import "OSEssenceViewController.h"
#import "OSFriendTrendsViewController.h"
#import "OSMeViewController.h"
#import "OSNewViewController.h"
#import "OSTabBar.h"
#import "OSNavgationViewController.h"
@implementation OSTabBarController


+(void)initialize{
    [super initialize];
    
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    attrs[NSForegroundColorAttributeName] = [UIColor lightGrayColor];
    NSMutableDictionary *selectAttrs = [NSMutableDictionary dictionary];
    
    selectAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    selectAttrs[NSForegroundColorAttributeName] = [UIColor darkGrayColor];
    
    UITabBarItem *item = [UITabBarItem appearance];
    
    [item setTitleTextAttributes:attrs forState:UIControlStateNormal];
    [item setTitleTextAttributes:selectAttrs forState:UIControlStateSelected];
}

-(void)viewDidLoad{
    [super viewDidLoad];
    
    
    OSEssenceViewController *vc = [[OSEssenceViewController alloc]init];
    [self addChildViewController:vc withTitle:@"精华" withImageName:@"tabBar_essence_icon" withSelectImageName:@"tabBar_essence_click_icon"];
    
    
    OSNewViewController *vc1 = [[OSNewViewController alloc]init];
    [self addChildViewController:vc1 withTitle:@"新帖" withImageName:@"tabBar_new_icon" withSelectImageName:@"tabBar_new_click_icon"];
    
    OSFriendTrendsViewController *vc2 = [[OSFriendTrendsViewController alloc]init];
    [self addChildViewController:vc2 withTitle:@"关注" withImageName:@"tabBar_friendTrends_icon" withSelectImageName:@"tabBar_friendTrends_click_icon"];
    
    OSMeViewController *vc3 = [[OSMeViewController alloc]initWithStyle:UITableViewStyleGrouped];
    [self addChildViewController:vc3 withTitle:@"我" withImageName:@"tabBar_me_icon" withSelectImageName:@"tabBar_me_click_icon"];
    
    [self setValue:[[OSTabBar alloc]init] forKeyPath:@"tabBar"];
    
}


-(void)addChildViewController:(UIViewController *)childController withTitle:(NSString*)title withImageName:(NSString*)imageName withSelectImageName:(NSString*)selectImageName{
    
    

    childController.tabBarItem.title = title;
    childController.tabBarItem.image = [UIImage imageNamed:imageName];
    childController.tabBarItem.selectedImage = [UIImage imageNamed:selectImageName];
    
    
    OSNavgationViewController *nav = [[OSNavgationViewController alloc]initWithRootViewController:childController];
    
    
    [self addChildViewController:nav];
    
    
    
    
    
    
}


@end
